// ===============================================
// app_theme
// 
// Create by Will on 2020/10/5 6:17 PM
// Copyright @flutter_base.All rights reserved.
// ===============================================

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

AppCustomThemeData themeOf(BuildContext context) {
  final brightness = MediaQuery.of(context).platformBrightness;
  switch (brightness) {
    case Brightness.light:
      return const AppCustomThemeData(
        listTileColor: CupertinoColors.systemBackground,
      );
    case Brightness.dark:
      return const AppCustomThemeData(
        listTileColor: CupertinoColors.darkBackgroundGray,
      );
  }
}

ThemeData appThemeData(Brightness brightness) {
  final cupertinoThemeData = appCupertinoThemeData(brightness);
  final customThemeData = const AppCustomThemeData();

  return ThemeData(
    brightness: cupertinoThemeData.brightness,
    primaryColor: cupertinoThemeData.primaryColor,
    scaffoldBackgroundColor: cupertinoThemeData.scaffoldBackgroundColor,
    splashColor: Colors.transparent,
    cupertinoOverrideTheme: cupertinoThemeData,
    dividerTheme: DividerThemeData(
      color: customThemeData.dividerColor,
      space: 0,
      thickness: 0.5,
      indent: 13,
      endIndent: 2,
    ),
  );
}

CupertinoThemeData appCupertinoThemeData(Brightness brightness) {
  return CupertinoThemeData(
    brightness: brightness,
    primaryColor: const Color(0xff3ea1ff),
    primaryContrastingColor: const Color(0xff618cef),
    barBackgroundColor: const CupertinoDynamicColor.withBrightness(
      color: Color(0xFFF9F9F9),
      darkColor: Color(0xFF1D1D1D),
      // Values extracted from navigation bar. For toolbar or tabbar the dark color is 0xF0161616.
    ),
    scaffoldBackgroundColor: const CupertinoDynamicColor(
      color: Color(0xFFF8FBFE),
      darkColor: Color.fromARGB(255, 0, 0, 0),
      highContrastColor: Color.fromARGB(255, 255, 255, 255),
      darkHighContrastColor: Color.fromARGB(255, 0, 0, 0),
      elevatedColor: Color.fromARGB(255, 255, 255, 255),
      darkElevatedColor: Color.fromARGB(255, 28, 28, 30),
      highContrastElevatedColor: Color.fromARGB(255, 255, 255, 255),
      darkHighContrastElevatedColor: Color.fromARGB(255, 36, 36, 38),
    ),
    textTheme: const CupertinoTextThemeData(
        textStyle: const TextStyle(
          color: CupertinoDynamicColor.withBrightness(
            color: CupertinoColors.black,
            darkColor: CupertinoColors.white,
          ),
          fontSize: 17,
        ),
        actionTextStyle: const TextStyle(
          color: const Color(0xffC0C0C0),
        ),
        navActionTextStyle: const TextStyle(
          color: const Color(0xffff0000),
        )
    ),
  );
}

class AppCustomThemeData {
  // 用于普通级段落信息引导词
  final TextStyle secondaryTextStyle;

  // 用于辅助、次要的文字信息、普通按钮描边
  final TextStyle auxiliaryText;

  // 用于需要输入文字框内的提示性文字
  final TextStyle hintText;

  final Color backButtonColor;

  // 分割线颜色
  final Color dividerColor;

  // 密封线颜色
  final Color sealingLineColor;

  final Color listTileColor;

  // 在线搭配颜色
  final Color onlineColor;

  // 在线搭配颜色
  final Color tabActiveColor;

  final Color userLabelColor;

  // vip 背景颜色
  final Color vipBackgroundColor;

  // 消息气泡
  final BoxDecoration receiveMessageBubbleDecoration;

  const AppCustomThemeData({
    this.secondaryTextStyle = const TextStyle(
      color: Color(0xff707070),
    ),
    this.auxiliaryText = const TextStyle(
      color: Color(0xff5f5f5f),
      fontWeight: FontWeight.w300,
    ),
    this.hintText = const TextStyle(
      color: Color(0xff8f8f8f),
      height: 1,
    ),
    this.backButtonColor = const CupertinoDynamicColor.withBrightness(
      color: Color(0xFF1A1A1A),
      darkColor: CupertinoColors.white,
    ),
    this.dividerColor = const Color(0xffdce2e9),
    this.sealingLineColor = const Color(0xffd1d1d1),
    this.listTileColor = CupertinoColors.systemBackground,
    this.onlineColor = const Color(0xffDCF4E6),
    this.tabActiveColor = const Color(0xffff0000),
    this.vipBackgroundColor = const Color(0xff4A4C6C),
    this.userLabelColor = const Color(0xffEBEFF2),
    this.receiveMessageBubbleDecoration = const BoxDecoration(
      color: const CupertinoDynamicColor.withBrightness(
        color: CupertinoColors.white,
        darkColor: CupertinoColors.black,
      ),
      borderRadius: BorderRadius.all(Radius.circular(5)),
    ),
  });

// BoxDecoration selectBubbleDecoration(Direction direction) {
//   switch (direction) {
//     case Direction.RECEIVE:
//       return receiveMessageBubbleDecoration;
//     case Direction.SEND:
//       return sendMessageBubbleDecoration;
//   }
// }
//
// TextStyle selectBubbleTextStyle(Direction direction) {
//   switch (direction) {
//     case Direction.RECEIVE:
//       return receiveMessageBubbleTextStyle;
//     case Direction.SEND:
//       return sendMessageBubbleTextStyle;
//   }
// }
}

